﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LogView.aspx.cs" Inherits="Yule8xWechat.LogView" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        body {
            font-size: 12px;
            line-height: 21px;
        }

        a {
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div><a href='?action=deleteqrimg' onclick='return confirm(\"您确定要删除所有微信二维码吗?\");'>删除微信二维码图片缓存</a> <a href='?action=deletelogs' onclick='return confirm(\"您确定要删除全部日志文件吗\")'>删除全部日志</a></div>
    <div style="margin-bottom: 5px; border-bottom: solid 1px #CCC; padding-bottom: 5px;">
        <%
            string dellink = "", url;
            foreach (string dir in dirs)
            {
                if (!string.IsNullOrEmpty(cur_dir) && cur_dir == dir)
                {
                    Response.Write("<a href='?dir=" + dir + "' style='font-weight:bold;'>[" + dir + "]</a> | ");
                }
                else
                {
                    Response.Write("<a href='?dir=" + dir + "'>[" + dir + "]</a> | ");
                }
            }
        %>
    </div>
    <div style="max-height: 180px; overflow: auto; width: 250px;">
        <%
            if (!string.IsNullOrEmpty(cur_dir))
            {
                dellink = "<a href='?dir=" + cur_dir + "&file={0}&action=delete' onclick=\"return confirm('您确定要删除该文件吗?')\">[删除]</a>";
                IList<string> files = GetFiles(cur_dir);
                foreach (string file in files)
                {
                    url = string.Format("?dir={0}&file={1}", cur_dir, file);
                    //url = string.Format("Runtime/Log/{0}/{1}", cur_dir, file);
                    if (!string.IsNullOrEmpty(cur_file) && cur_file == file)
                    {
                        Response.Write(string.Format("<a href='{0}' style='font-weight:bold;'>[{1}]</a>{2}<br />", url, file, string.Format(dellink, file)));
                    }
                    else
                    {
                        Response.Write(string.Format("<a href='{0}'>[{1}]</a>{2}<br />", url, file, string.Format(dellink, file)));
                    }
                }
            }
        %>
    </div>
    <div>
        <%

            if (!string.IsNullOrEmpty(cur_file))
            {
                string content = GetFileContent(cur_dir, cur_file);
                Response.Write("<textarea cols='150' rows='39' style='width:99%'>" + content + "</textarea>");
            } %>
    </div>
</body>
</html>
